home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # fix_fig_dir sgml-file directory
- #
- # this tool looks through the book and removes extraneous CGM files
- # that are not needed
-
- # verify we have a SGML file and directory name specified
- SGML=$1
- if [ "$SGML" = "" ] ; then
- echo "Usage: clean_cgms sgml-file directory";
- exit;
- fi
- DIR=$2
- if [ "$DIR" = "" ] ; then
- echo "Usage: clean_cgms sgml-file directory";
- exit;
- fi
-
- # check to see that both exists
- if [ ! -f $SGML ] ; then
- echo "Usage: clean_cgms sgml-file directory";
- echo " SGML file non-existant";
- exit;
- fi
- if [ ! -d $DIR ] ; then
- echo "Usage: clean_cgms sgml-file directory";
- echo " directory non-existant";
- exit;
- fi
-
- # if no cgm files then don't bother doing any more work
- if [ ! -f $DIR/*.cgm* ] ; then
- exit;
- fi
-
- if [ "$TMPDIR" = "" ] ; then
- TMPDIR=/usr/tmp;
- fi
-
- TMPFILE1=$TMPDIR/cgm_sgml.tmp.$$
- TMPFILE2=$TMPDIR/cgm_dir.tmp.$$
-
- grep "<GRAPHIC" $SGML | sed 's/.*FILE="\(.*\)" POS.*/\1/' | sed '/<\/FIGURE>/d' | grep '\.cgm' | sort -u > $TMPFILE1
-
- CUR_DIR=`pwd`
- cd $DIR
-
- /bin/ls *.cgm* | sort -u > $TMPFILE2
-
- EXTRA=`comm -13 $TMPFILE1 $TMPFILE2`
-
- /bin/rm -f $EXTRA $TMPFILE1 $TMPFILE2
-
- cd $CUR_DIR
-